﻿@using LY.Business.ServiceImpl
@using LY.Entity
@using LY.Entity.Entities
@using LY.Interface
@{
    Layout = "~/Areas/Admin/Views/Shared/_LayoutCMS.cshtml";
    ViewBag.Title = "编辑项目信息";
    List<T_Document> list = ViewBag.Document;
    QJ.CMS.Areas.Admin.Controllers.T_ProjectController.rlist.Clear();//刷新页面时清除静态变量中缓存的值
}

@section htmlhead{
    <link href="~/Content/assets/css/Layout/css/main.css" rel="stylesheet" />
    <link href="~/Content/assets/css/plugin/validator.css" rel="stylesheet" />
    <script src="~/Content/assets/js/swfobject.js"></script>
    <script src="~/Content/assets/js/jquery.uploadify.v2.1.4.js"></script>
    <link href="~/Content/assets/css/plugin/xjgrid.css" rel="stylesheet" />
    <style type="text/css">
        .cp_img {
            float: left;
            margin-right: 16px;
            position: relative;
        }

            .cp_img img {
                width: 91px;
                height: 91px;
            }

        .shB {
            display: none;
        }

        #btnUploadImg {
            background-image: url(../../assets/img/upload.jpg);
            color: white;
            font-weight: 300;
            padding: 5px;
        }
    </style>
    <script src="~/Content/editor/kindeditor-min.js"></script>
    <script src="~/Content/editor/lang/zh_CN.js"></script>
}
@model LY.Entity.Entities.T_Project_EX
<div class="container">
    <div id="forms" class="mt10">
        <div class="box">
            <div class="box_border">
                <div class="box_top"><b class="pl15">编辑项目信息</b></div>
                <div class="box_center">
                    <form  id="frmEdit" method="post" action="@Url.Action("ProjectSave")" role="form" class="jqtransform">
                        <input id="id" name="id" value="@Model.ID" type="hidden" />
                        <input id="wid" name="wid" value="@Model.wid" type="hidden" />
                        <input id="rid" name="rid" value="@Model.rid" type="hidden" />
                        <input id="hideEName" name="hideEName" value="" type="hidden" />
                        <input id="Eid" name="Eid" value="@Model.EnterpriseID" type="hidden" />
                        <input id="LoanUser" name="LoanUser" value="@Model.LoanUser" type="hidden" />
                        <input id="RepaymentUser" name="RepaymentUser" value="@Model.RepaymentUser" type="hidden" />
                        <table class="form_table pt15 pb15" style="width: 100%;" border="0">
                            <tr>
                                <td class="td_right">项目编号：</td>
                                <td class="">
                                    <input type="text" id="ProjectNo" name="ProjectNo" value="@Model.ProjectNo" readonly="readonly" class="input-text lh30" size="40">
                                </td>
                                <td class="td_right">项目名称：</td>
                                <td class="">
                                    <input type="text" id="ProjectName" name="ProjectName" value="@Model.ProjectName" class="input-text lh30" size="40">
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right">借款总额：</td>
                                <td class="">
                                    <input type="text" onblur="util.getFloatStr(this.id,this.value);" id="TotalLoan" name="TotalLoan" value="@Model.TotalLoan" class="input-text lh30" size="40">
                                </td>

                                <td class="td_right">项目期限：</td>
                                <td class="">

                                    <input type="text" id="ProjectDuration" name="ProjectDuration" onblur="util.GetNums(this.id,this.value)"  value="@Model.ProjectDuration" class="input-text lh30" size="40">
                                    @Html.ResourceDropDownList("DurationMonthOrDay", "DurationMonthOrDay", Model.DurationMonthOrDay, new { @class = "select" })
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right">项目拆标：</td>
                                <td class="">
                                    @Html.ResourceRadioList("SubProject", "SubProject", Model.SubProject == null ? 0 : Model.SubProject, true)
                                </td>
                                <td class="td_right">每标金额：</td>
                                <td class="">
                                    <input type="text" onblur="util.getFloatStr(this.id,this.value);" id="EachSubProjectAmount" name="EachSubProjectAmount" value="@Model.EachSubProjectAmount" class="input-text lh30" size="40">
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right">最低额度：</td>
                                <td class="">
                                    <input type="text" onblur="util.getFloatStr(this.id,this.value);" id="MinTenderAmount" name="MinTenderAmount" value="@Model.MinTenderAmount" class="input-text lh30" size="40">
                                </td>
                                <td class="td_right">新手项目：</td>
                                <td class="">
                                    @Html.ResourceRadioList("IsNewProject", "IsNewProject", Model.IsNewProject == null ? 0 : Model.IsNewProject, true)
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right">年化利率：</td>
                                <td class="">
                                    <input type="text" onblur="util.GetNum(this.id,this.value)" id="AnnualisedRates" name="AnnualisedRates" value="@(Model.AnnualisedRates * 100)" class="input-text lh30" size="3">
                                    <span style="color: red;">%（范围：0-100）</span>
                                    <input type="text" onblur="util.GetNum(this.id,this.value)" id="AddAnnualisedRates" name="AddAnnualisedRates" value="@(Model.AddAnnualisedRates * 100)" class="input-text lh30" size="3">
                                    <span style="color: red;">%（范围：0-100）</span>
                                </td>

                                <td class="td_right">企业名称：</td>
                                <td class="">
                                    <label id="lbEnterpriseName" title="@ViewBag.EnterpriseName">@ViewBag.EnterpriseName</label>
                                    <input type="button" onclick="util.GetEnterpriseName(this.id)" id="btnAdd" name="button" class="btn btn82 btn_add" value="+" />
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right">企业代理人：</td>
                                <td class="">
                                    <input type="text" id="EnterpriseAgent" name="EnterpriseAgent" value="@Model.EnterpriseAgent" class="input-text lh30" size="40">
                                </td>

                                <td class="td_right">项目位置：</td>
                                <td class="">
                                    <input type="text" id="ProjectLocation" name="ProjectLocation" value="@Model.ProjectLocation" class="input-text lh30" size="40">
                                </td>
                            </tr>
                            <tr>
                                <td></td>
                                <td></td>
                                <td class="td_right">项目详细地址：</td>
                                <td class="">
                                    <input type="text" id="ProjectAddress" name="ProjectAddress" value="@Model.ProjectAddress" class="input-text lh30" size="40">
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right">项目开始日期：</td>
                                <td class="">
                                    <input type="text" id="ProjectBeginDate" onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' })" readonly="true" name="ProjectBeginDate" value="@Model.ProjectBeginDate" class="input-text lh30" size="40">
                                </td>
                                <td class="td_right">投标截止日期：</td>
                                <td class="">
                                    <input id="BiddingDeadline" type="hidden" value="@DateTime.Now" name="BiddingDeadline"/>
                                    <input type="text" id="ProjectEndDate" onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' })" readonly="true" name="ProjectEndDate" value="@Model.ProjectEndDate" class="input-text lh30" size="40">
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right">还款来源：</td>
                                <td class="">
                                    <input type="text" id="RepaymentSource" name="RepaymentSource" value="@Model.RepaymentSource" class="input-text lh30" size="40">
                                </td>
                                <td class="td_right">还款类型：</td>
                                <td class="">
                                    @Html.ResourceDropDownList("RepaymentType", "RepaymentType", Model.RepaymentType, new { @class = "select" })
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right">借款用途：</td>
                                <td class="">
                                    <input type="text" id="LoanPurpose" name="LoanPurpose" value="@Model.LoanPurpose" class="input-text lh30" size="40">
                                </td>
                                <td class="td_right">借款类型：</td>
                                <td class="">
                                    @Html.ResourceDropDownList("LoanType", "LoanType", Model.LoanType, new { @class = "select" })
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right"></td>
                                <td class=""></td>
                            </tr>
                            <tr>
                                <td class="td_right">项目详情：</td>
                                <td class="" colspan="3">
                                    <textarea id="editor1" name="editor1" style="width: 90%; height: 100px;">@Model.ProjectDetail</textarea>
                                    <input type="hidden" id="hideProjectDetail" name="ProjectDetail" />
                                </td>

                            </tr>
                            <tr>
                                <td><b class="pl15">风控信息</b></td>
                            </tr>
                            <tr>
                                <td class="td_right">担保方：</td>
                                <td class="">
                                    <input type="text" id="AssuranceProvider" name="AssuranceProvider" value="@Model.AssuranceProvider" class="input-text lh30" size="40">
                                </td>

                                <td class="td_right">担保情况：</td>
                                <td class="">
                                    <input type="text" id="AssuranceSituation" name="AssuranceSituation" value="@Model.AssuranceSituation" class="input-text lh30" size="40">
                                </td>
                            </tr>

                            <tr>
                                <td class="td_right">风控详情：</td>
                                <td class="" colspan="3">
                                    @*<input type="text" id="ContractAgreement" name="ContractAgreement" value="@Model.ContractAgreement" class="input-text lh30" size="40">*@
                                    <textarea id="editor" name="editor" style="width: 90%; height: 180px;">@Model.FKRemark</textarea>
                                    <input type="hidden" id="hideRemark" name="FKRemark" />
                                </td>
                            </tr>

                            <tr>
                                <td><b class="pl15 td_right">相关文件：</b></td>
                                <td class="" colspan="3">
                                    <div id="fileList1">
                                        @if (list != null)
                                        {
                                            for (var i = 0; i < list.Count; i++)
                                            {
                                                if (list[i].Type == 1)
                                                {
                                            <div id="@list[i].Id" class="cp_img" onclick="deleteImg(@list[i].Id)">
                                                <img src="@list[i].DocPath" />
                                                <div class="cp_img_jian"></div>
                                            </div>
                                                }

                                            }
                                        }
                                    </div>
                                    <div class="cp_img_jia" id="filePicker1"></div>
                                </td>
                            </tr>

                            <tr>
                                <td><b class="pl15 td_right">实地照片：</b></td>
                                <td class="" colspan="3">
                                    <div id="fileList2">
                                        @if (list != null)
                                        {
                                            for (var i = 0; i < list.Count; i++)
                                            {
                                                if (list[i].Type == 2)
                                                {
                                            <div id="@list[i].Id" class="cp_img" onclick=" deleteImg(@list[i].Id) ">
                                                <img src="@list[i].DocPath" />
                                                <div class="cp_img_jian"></div>
                                            </div>
                                                }
                                            }
                                        }
                                    </div>
                                    <div class="cp_img_jia" id="filePicker2"></div>
                                </td>
                            </tr>

                            <tr>
                                <td><b class="pl15 td_right">货后跟踪：</b></td>
                                <td class="" colspan="3">
                                    <div id="fileList3">
                                        @if (list != null)
                                        {
                                            for (var i = 0; i < list.Count; i++)
                                            {
                                                if (list[i].Type == 3)
                                                {
                                            <div id="@list[i].Id" class="cp_img" onclick=" deleteImg(@list[i].Id) ">
                                                <img src="@list[i].DocPath" />
                                                <div class="cp_img_jian"></div>
                                            </div>
                                                }
                                            }
                                        }
                                    </div>
                                    <div class="cp_img_jia" id="filePicker3"></div>
                                </td>
                            </tr>

                            <tr>
                                <td><b class="pl15 td_right">保证合同：</b></td>
                                <td class="" colspan="3">
                                    <div id="fileList4">
                                        @if (list != null)
                                        {
                                            for (var i = 0; i < list.Count; i++)
                                            {
                                                if (list[i].Type == 4)
                                                {
                                            <div id="@list[i].Id" class="cp_img" onclick=" deleteImg(@list[i].Id) ">
                                                <img src="@list[i].DocPath" />
                                                <div class="cp_img_jian"></div>
                                            </div>
                                                }
                                            }
                                        }
                                    </div>
                                    <div class="cp_img_jia" id="filePicker4"></div>
                                </td>
                            </tr>

                            <tr>
                                <td><b class="pl15 td_right">承租人证件：</b></td>
                                <td class="" colspan="3">
                                    <div id="fileList5">
                                        @if (list != null)
                                        {
                                            for (var i = 0; i < list.Count; i++)
                                            {
                                                if (list[i].Type == 5)
                                                {
                                            <div id="@list[i].Id" class="cp_img" onclick=" deleteImg(@list[i].Id) ">
                                                <img src="@list[i].DocPath" />
                                                <div class="cp_img_jian"></div>
                                            </div>
                                                }
                                            }
                                        }
                                    </div>
                                    <div class="cp_img_jia" id="filePicker5"></div>
                                </td>
                            </tr>

                            <tr>
                                <td><b class="pl15 td_right">其他：</b></td>
                                <td class="" colspan="3">
                                    <div id="fileList6">
                                        @if (list != null)
                                        {
                                            for (var i = 0; i < list.Count; i++)
                                            {
                                                if (list[i].Type == 6)
                                                {
                                            <div id="@list[i].Id" class="cp_img" onclick=" deleteImg(@list[i].Id) ">
                                                <img src="@list[i].DocPath" />
                                                <div class="cp_img_jian"></div>
                                            </div>
                                                }
                                            }
                                        }
                                    </div>
                                    <div class="cp_img_jia" id="filePicker6"></div>
                                </td>
                                <input id="hid_pic" name="hid_pic" type="hidden" value="" />
                            </tr>

                            <tr>
                                <td><b class="pl15">风控审核报告</b></td>
                            </tr>

                            <tr>
                                <td class="td_right">身份证：</td>
                                <td class="">
                                    @Html.ResourceDropDownList("VerifyIdCard", "YesOrNo", Model.VerifyIdCard, new { @class = "select" })
                                </td>
                                <td class="td_right">结（离）婚证：</td>
                                <td class="">
                                    @Html.ResourceDropDownList("VerifyIsMarriage", "YesOrNo", Model.VerifyIsMarriage, new { @class = "select" })
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right">户口本：</td>
                                <td class="">
                                    @Html.ResourceDropDownList("VerifyBooklets", "YesOrNo", Model.VerifyBooklets, new { @class = "select" })
                                </td>
                                <td class="td_right">房产证：</td>
                                <td class="">
                                    @Html.ResourceDropDownList("VerifyHouseProperty", "YesOrNo", Model.VerifyHouseProperty, new { @class = "select" })
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right">银行流水：</td>
                                <td class="">
                                    @Html.ResourceDropDownList("VerifyBankWater", "YesOrNo", Model.VerifyBankWater, new { @class = "select" })
                                </td>
                                <td class="td_right">房地产登记簿：</td>
                                <td class="">
                                    @Html.ResourceDropDownList("VerifyRealEstateBook", "YesOrNo", Model.VerifyRealEstateBook, new { @class = "select" })
                                </td>
                            </tr>
                            <tr>
                                <td class="td_right">征信报告：</td>
                                <td class="">
                                    @Html.ResourceDropDownList("VerifyCreditReporter", "YesOrNo", Model.VerifyCreditReporter, new { @class = "select" })
                                </td>
                                <td class="td_right">他项权证：</td>
                                <td class="">
                                    @Html.ResourceDropDownList("VerifyOthers", "YesOrNo", Model.VerifyOthers, new { @class = "select" })
                                </td>
                            </tr>

                            <tr>
                                <td class="td_center" colspan="4">
                                    <input type="button" id="btnSave" name="button" class="btn btn82 btn_save2" value="保存">
                                    <input type="button" id="btnReturn" name="button" class="btn btn82 btn_res" value="返回">
                                </td>
                            </tr>

                            <tr>
                                <td class="td_right"></td>
                                <td>&nbsp;
                                </td>
                                <td class="td_right"></td>
                                <td>&nbsp;
                                </td>
                            </tr>
                        </table>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

@section jssection{
    <script type="text/javascript">
        var util = {};
        var options = {
            companyUrl: "@Url.Action("CompanyIndex")",//获取企业名称
            deleteUrl: "@Url.Action("RelementDelete")",
            uploadUrl: "@Url.Action("UploadImg", "Helper")",
            Loan: "@Url.Action("Loan")",
            Audit: "@Url.Action("Audit")",
            Rept: "@Url.Action("Rept")",
            listUrl: "@Url.Action("RelementPlanList")",
            Repayment: "@Url.Action("Repayment")"
        };

        $("#btnSave").click(function () {
            if ($('input[name="SubProject"]').filter(':checked').val() == "1") {
                if ($('#EachSubProjectAmount').val() != "") {
                    //$('#uploadify').uploadifyUpload();
                    $("#hideRemark").val($("#editor").val());
                    $("#hideProjectDetail").val($("#editor1").val());

                    setInterval($("#frmEdit").submit(), 1000);
                } else {
                    alert('请填写每标金额！');
                }
            } else {
                $("#hideRemark").val($("#editor").val());
                $("#hideProjectDetail").val($("#editor1").val());
                //$('#uploadify').uploadifyUpload();
                setInterval($("#frmEdit").submit(), 1000);
            }
        });
    </script>

    <script src="~/Content/assets/plugins/validator/validator.js"></script>
    <script src="~/Content/assets/js/common.js"></script>
    <script src="~/Content/assets/DatePicker/WdatePicker.js"></script>
    <script src="~/Content/assets/layer/layer.min.js"></script>
    <script src="~/Content/assets/app/t_project/ProjectEdit.js"></script>



    <!-- 批量上传图片-->
    <link href="~/webuploader/css/webuploader.css" rel="stylesheet" />
    <link href="~/webuploader/css/style.css" rel="stylesheet" />
    <link href="~/webuploader/css/demo.css" rel="stylesheet" />


    <script src="~/webuploader/js/jquery-1.8.2.min.js"></script>
    <script src="~/webuploader/js/webuploader.js"></script>
    <script src="~/webuploader/ImageJS.js"></script>



    <script type="text/ecmascript">
        KindEditor.ready(function (K) {

            window.editor = K.create('textarea', {
                resizeType: 1,
                allowPreviewEmoticons: false,
                allowImageUpload: true,
                minWidth: 350,
                allowFileManager: true,
                afterBlur: function () {
                    this.sync();
                }
            });
        });
        $(function () {
            //编辑器


            var url = "/T_Project/UpLoadProcess?op=";
            upload("#fileList1", "#filePicker1", url + "1", true); //相关文件
            upload("#fileList2", "#filePicker2", url + "2", true); //实地照片
            upload("#fileList3", "#filePicker3", url + "3", true); //货后跟踪
            upload("#fileList4", "#filePicker4", url + "4", true); //保证合同
            upload("#fileList5", "#filePicker5", url + "5", true); //承租人证件
            upload("#fileList6", "#filePicker6", url + "6", true); //其他
        });


        $(".imgShow").click(function (e) {
            $("#newImgShow").attr("src", this.src);
            var left = $(this).offset().left;
            var top = $(this).offset().top;
            $("#imgShowDiv").css({ "left": left, "top": top });
            $("#imgShowDiv").show();
        });

        function deleteImg(id) {
            if (confirm("确定删除吗？确定之后即时删除！")) {
                $.post("/T_Project/DeleteImages?id=" + id, function (r) {
                    if (r.Status == 1) {
                        $("#" + id).remove();
                    }
                });
            }
        }

    </script>
}
